extends Skill
func init():
	name = "传火"
	dec = "每次击杀都会提升你的力量，即使是死亡，这份力量也不会消失。"
	isIco = true
	
var lvpower = 0 #力量层数，与lv区分防止眼瞎
var backatk = 0
var backhp = 0
var oldcry = 0
var cardname = null
var powerpass = null
func setLv(lv):
	self.lvpower = lv
	name = "传火%d"%self.lvpower
	card.att.atk = (lvpower+backatk)
	card.att.maxHp = (lvpower+backhp)
	if powerpass == null :
		cardname = Label.new()
		cardname.text = "新的传承者已出现"
		cardname.margin_left = 30
		cardname.margin_right = 150
		cardname.margin_top = 590
		sys.scene.add_child(cardname)
		powerpass = Label.new()
		powerpass.text = "已获取%d份力量！"%lvpower
		powerpass.margin_left = 30
		powerpass.margin_right = 150
		powerpass.margin_top = 620
		sys.scene.add_child(powerpass)
	else:
		cardname.text = "新的传承者已出现"
		powerpass.text = "已获取%d份力量！"%lvpower
	return self

func _connect():
	backatk = card.att.atk
	backhp = card.att.maxHp
	sys.scene.connect("onCardDeath",self,"e1")
	card.connect("onDeath",self,"runDeath")

func e1(atkInfo:AtkInfo):
	if atkInfo.atkCard == card || atkInfo.hitCard == card :
		var k = card.getSkill("k_wuhuo_bonefire_lit")
		if  k != null && k.lvpower < 9 :
			lvpower += 1
			k.setLv(lvpower)
		else:	
			lvpower += 1
			var c = card.getHero().newCard("c_wuhuo_monster")	
			card.getHero().hand.addCard(c)
			c.lvpower += lvpower
			lvpower = 0
			setLv(lvpower)
			cardname.text = ""
			powerpass.text = ""
			sys.newAcpDlg("传承的力量？被转移了？")
			card.delSkill(self)
	else:return
func runDeath(atkInfo):
	if card.getHero() == sys.scene.heros[0] :
		var c = card.getHero().newCard("c_wuhuo_bonefire")
		card.getHero().hand.addCard(c)
		c.att.cry += (2+oldcry)
		c.lvpower += lvpower
		if c.att.cry >=11 :
			cardname.text = "传承失败！你受到了惩罚！"
			powerpass.text = ""
			card.hurtCard(c.getHero(),999)
			return
	else:
		var c = card.getHero().getOppHero().newCard("c_wuhuo_bonefire")
		card.getHero().getOppHero().hand.addCard(c)
		c.att.cry += (2+oldcry)
		c.lvpower += lvpower
		if c.att.cry >=11 :
			cardname.text = "传承失败！你受到了惩罚！"
			powerpass.text = ""
			card.hurtCard(c.getHero().getOppHero(),999)
			return
	cardname.text = ""
	powerpass.text = ""
	card.delSkill(self)